package realQuestion.tuan;

import java.util.HashMap;
import java.util.Scanner;

public class Test1 {

    public    boolean  judge(int[] nums,int x,int y){
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i],i);
        }
      int a = map.get(x);
      int b= map.get(y);
       return  Math.abs(a-b)==1?true:false;

    }


    public static void main(String[] args) {
        Scanner   in  = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int[] nums = new int[n];

        for (int i = 0; i < n; i++) {
            nums[i]=in.nextInt();
        }
//
//        while (in.hasNextInt()) { // 注意 while 处理多个 case
//            int a = in.nextInt();
//            int b = in.nextInt();
//            System.out.println(a + b);
//        }
        int x=in.nextInt();
        int y=in.nextInt();

        Test1 test1 = new Test1();
        System.out.println(test1.judge(nums, x, y));


    }

}
